using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{
    public partial class VICC_MULLANG
    {

        public void InsertICC_MULLANG(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                default:
                case "50.24":
                    or1.CommandText = "INSERT INTO ICC_MULLANG(MANDANT, ROWNID, MLLOC,MLKEY, EN, SCN)"
                                + " VALUES (:MANDANT:,SEQ_ICC_ITX.NEXTVAL,:MLLOC:, :MLKEY:, :EN:, :SCN:)";
                    break; 
            }
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public override void BATCHINSERT()
        {
            base.BATCHINSERT();
        }
        public override string BATCHINSERT(DataRow dwData)
        {
            string value = "";
            switch (app.company)
            {
                default:
                case "SXN":
                case "YGR":
                case "TST":
                    value = "INTO ICC_MULLANG "
                                    + " VALUES (:MANDANT:,SEQ_ICC_ITX.NEXTVAL, :MLKEY:, :EN:, :SCN:,:MLLOC:)";
                    value = INTEXDBC.InjectData(value, dwData);
                    break;
            }
            return value;
        }

        public void DMUL00(DataRow dwData)
        {

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ICC_MULLANG"
               + " WHERE MANDANT=:MANDANT:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void DMUL01(DataRow dwData)
        {

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ICC_MULLANG"
               + " WHERE MANDANT=:MANDANT: AND ROWNID=:ROWNID:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void DMUL02(DataRow dwData)
        {

            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ICC_MULLANG"
               + " WHERE MANDANT=:MANDANT: AND MLLOC=:MLLOC:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public DataSet QueryICC_MULLANG(DataRow dwData, int option = 1)
        { 
            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    SResult = QMUL01(dwData); 
                    break;
                case 2:
                    SResult = QMUL02(dwData);  
                    break;
                case 3:
                    SResult = QMUL03(dwData); 
                    break;
                case 9999:
                    SResult = QMUL9999(dwData); 
                    break; 
            } 
            return SResult;
        }
        public DataSet QMUL01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = " SELECT * FROM ICC_MULLANG WHERE MANDANT=:MANDANT: AND ROWNID=:ROWNID:"; ;
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QMUL02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = " SELECT * FROM ICC_MULLANG"
                + " WHERE MANDANT=:MANDANT: AND MLLOC=:MLLOC: "
                + dwData["EN"].ToString();
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QMUL03(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = " SELECT * FROM ICC_MULLANG WHERE MANDANT=:MANDANT: AND MLKEY=:MLKEY: AND MLLOC=:MLLOC:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QMUL9999(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = " SELECT * FROM ICC_MULLANG WHERE MANDANT=:MANDANT:"
                                + dwData["EN"].ToString()
                                +dwData["MLLOC"].ToString()
                                + " ORDER BY MLLOC,MLKEY";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void UpdateICC_MULLANG(DataRow dwData,int option=1)
        {
            if (option == 0)
            {
                switch (app.company)
                {
                    default:
                        UMUL01(dwData);
                        break;
                }
            }
          
        }
        public void UMUL01(DataRow dwData )
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE ICC_MULLANG SET MLLOC=:MLLOC:, MLKEY=:MLKEY:,  EN=:EN:, SCN=:SCN: "
                + " WHERE MANDANT=:MANDANT: AND ROWNID=:ROWNID: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void UMUL02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE ICC_MULLANG SET EN=:EN:, SCN=:SCN: "
                + " WHERE MANDANT=:MANDANT: AND MLKEY=:MLKEY:  ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
    }
}
